<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="css/new_file.css"/>
		<script type="text/javascript" src="js/jquery-3.1.1.js" ></script>
		<script type="text/javascript" src="js/bootstrap.min.js" ></script>
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="col-lg-6 col-xs-6 col-lg-offset-1 col-xs-offset-1">
					<div class="row reg">
						<div class="col-lg-12 col-xs-12">
							<div class="input-group input-group-lg">
								<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
								<input type="text" class="form-control" id="accountOut" placeholder="转出人ID" aria-describedby="basic-addon1">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-lg-12 col-xs-12">
							<div class="input-group input-group-lg">
								<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
								<input type="text" class="form-control" id="accountIn" placeholder="转入人ID" aria-describedby="basic-addon1">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-lg-12 col-xs-12">
							<div class="input-group input-group-lg">
								<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
								<input type="text" class="form-control" id="money" placeholder="转入金额" aria-describedby="basic-addon1">
							</div>
						</div>
					</div>

					<div class="row">
						<div class="col-lg-8 col-xs-8 col-lg-offset-2 col-xs-offset-2">
							<input type="button" id="sub" class="btn btn-lg btn-primary btn-block" value="提交" />
						</div>
					</div>
				</div>

				<div class="col-lg-4 col-lg-offset-1  col-xs-4 col-xs-offset-1">
					<table class="table table-bordered" id="ta">
						<tr>
							<th>账户</th>
							<th>余额</th>
						</tr>
<!-- 						<tr>
							<td></td>
							<td></td>
						</tr> -->
					</table>
				</div>
			</div>
		</div>
		
		<script type="text/javascript">
			$(function(){
				list();
				$("#sub").click(function(){
					var accountout = $("#accountOut").val();
					var accountin = $("#accountIn").val();
					var money = $("#money").val();
					$.post("/account/transfer",{"accountOut":accountout,"accountIn":accountin,"money":money},function(data){
						console.log(data);
//						var data = JSON.parse(data);
						console.log(data);
						if (data.code == "1") {
							alert(data.tip);
							list();
						} else{
							alert(data.tip);
                            list();
						}
					})
				})
				
			})

			function  list() {
				$.post("/account/getaccountinfo",{},function (data) {
//                    var data = JSON.parse(data);
                    if (data.code == "1") {
                    	 $("#ta").empty();
                    	 $("#ta").append("<tr><th>账户</th><th>余额</th></tr>");
                        for(var i=0;i<data.data.length;i++){
                            var str = '<tr><td>'+data.data[i].accountId+'</td>'+
                            '<td>'+ data.data[i].accountMoney +'</td></tr>';
                            $("#ta").append(str);
						}
                    } else{
                        alert(data.tip);
                    }
                })
            }
		</script>
	</body>
</html>
